<?php

Zend_Loader::loadClass("Zend_Log");
class St_Log extends Zend_Log
{
    private $_userId = 0;

    public function  __construct(Zend_Log_Writer_Abstract $writer = null) {
        parent::__construct($writer);
    }

    public function log($message, $userId = false) {
        $this->setEventItem('DateTime', time());
        $this->setEventItem('IPAddress', $_SERVER['REMOTE_ADDR']);
        $this->setEventItem('TransactionText', $message);
        if($userId){
            $this->setEventItem('UserID', $userId);
        } else {
            $this->setEventItem('UserID', $this->_userId);
        }
        
        parent::log("ST log", 1);
    }

    public function setUserId($id)
    {
        $this->_userId = $id;
    }
}